package com.mowh.multithreading.worker.thread.worker;

/**
 * @author mowh1gd
 * @create 2023/11/23 15:03
 */
public class WorkerThread extends Thread {//扮演Worker角色
    private final Channel channel;

    public WorkerThread(String name, Channel channel) {
        super(name);
        this.channel = channel;
    }

    @Override
    public void run() {
        while (true) {
            Request request = channel.takeRequest();//在channel中取出请求
            request.execute();//取出请求后执行（即具体的处理请求的方法），调用与执行分离
        }
    }
}
